package liangtWorkSpace.strategy.comparableFile;

/**
 * @ClassName Cat
 * @Description : 功能说明
 * @Author : LiangT
 * @Date : 2020/4/10 17:43
 */

public class Cat implements Comparable {
    public int weight,height;

    @Override
    public String toString() {
        return "Cat{" +
                "weight=" + weight +
                ", height=" + height +
                '}';
    }

    public Cat(int weight, int height) {
        this.weight = weight;
        this.height = height;
    }

    @Override
    public int comparetTo(Object o) {
        return compareTo((Cat) o);
    }

    public int compareTo(Cat cat){
        if (this.weight < cat.weight) return  -1;
        else if (this.weight > cat.weight) return 1;
        else return 0;
    }
    public static void main(String[] args) {
        Cat[] cats = new Cat[3];
        for (int i = 0; i < cats.length;i++){
            cats[i] = new Cat(i+1,i);
        }
        Sorter sorter = new Sorter();
        sorter.sort(cats);
    }

}
